<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html>
 <head>
    <title>库存报表</title>
	<%@ include file="/common/meta.jsp" %>
	<script src="${ctx}/js/ligerUI/js/plugins/ligerLayout.js" type="text/javascript"></script>
	<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/logic/Reports";
		var basic_WUrl="/logic/Reports";
		var basic_Title="库存报表";
		var grid;
		function createSearch(){
			init(1,8,'80,100,80,100,80,100,80,100','10%');
			//第一行的数据
			addCommon(0,0,"lable","物料编码：");
			addCommon(0,1,"txtlike","zd004MaterialsCode");
			addCommon(0,2,"lable","物料名称：");
			addCommon(0,3,"txtlike","zd005MaterialsName");
			addCommon(0,4,"lable","PI编号：");
			addCommon(0,5,"txtlike","zd026PiCode");
			addCommon(0,6,"lable","仓库：");
 			addCommon(0,7,"selectEnum","zd001WhName","<option></option><c:forEach var="s" items="${wh}"><option value='${s.zd003Name}'>${s.zd003Name}</option></c:forEach>");
 			init(2,8,'80,100,80,100,80,100,80,100','10%');
 			addCommon(1,0,"lable","客户：");
			addCommon(1,1,"txtlike","zd028CustomerName");
			addCommon(1,2,"lable","型号：");
			addCommon(1,3,"txtlike","zd007MaterialsModel");
			addCommon(1,4,"lable","规格：");
			addCommon(1,5,"txtlike","zd006MaterialsSpec");
		}
		
		function searchAP(){
			multipleSearch("#table1",true,"",basic_Url+"/WHInventoryList.do");
		}
		document.onkeydown=keyListener;   
		function keyListener(e){   
		    e = e ? e : event;  
		    if(e.keyCode == 13){   
		    	searchAP();
		    }   
		}  	
		$(function(){
			grid = $("#table1").ligerGrid({
		        columns: [
		                  { display: '仓库编码', name: 'zd001WhCode', width: 120 },
		                  { display: '仓库名称', name: 'zd001WhName', width: 100},
		                  { display: '仓位编码', name: 'zd002WhLocationCode', width: 1,hide:true},
		                  { display: '仓位名称', name: 'zd002WhLocationName', width:1,hide:true},
		                  { display: '仓位名称', name: 'zd002WhLocationId', width:1,hide:true},
		                  { display: '物料编码', name: 'zd004MaterialsCode', width: 120},
		                  { display: '物料名称', name: 'zd005MaterialsName', width:100},
		                  { display: '物料型号', name: 'zd007MaterialsModel', width:100},
		                  { display: '物料规格', name: 'zd006MaterialsSpec', width:100},
		                  { display: '物料颜色', name: 'zd008MaterialsColor', width:100},
		                  { display: '物料材质', name: 'zd008MaterialsQuanlity', width:100},
		                  { display: '单位', name: 'zd008Unit', width:80},
		                  { display: 'PI号', name: 'zd026PiCode', width: 120},
		                  { display: '客户名称', name: 'zd028CustomerName', width: 120},
		                  { display: '入库价格', name: 'zd024Price', width: 100,render: function (item){
		                		if(item.zd024Price==''||item.zd024Price==null||parseFloat(item.zd024Price)==0){
		                			return '0.0000';
		                		}
		                	 	return item.zd024Price.toFixed(4);
		                	}
		                  },
		                  { display: '总库存', name: 'zd009Quantity', width: 100,render: function (item){
		                		  if(item.zd009Quantity==''||item.zd009Quantity==null||parseFloat(item.zd009Quantity)==0){
		                		  	return '0.0000';
		                		  }
			                	  return item.zd009Quantity.toFixed(4);
	                  	  	}
		                  },
		                 {display: '库存金额', name: 'stockPrice', width: 100,render: function (item){
		                	 	return item.stockPrice.toFixed(4);
	               	 	 	}
		                 },
		                  /* { display: '在途库存', name: 'zd011TravelingQuantity',width: 100,
			                	render: function (item){
			                		if(item.zd011TravelingQuantity==''||item.zd011TravelingQuantity==null||parseFloat(item.zd011TravelingQuantity)==0){
			                			return '0.0000';
			                		}
			                	 return item.zd011TravelingQuantity.toFixed(4);
			                }}, */ 
			               /*  { display: '总库存', name: 'stocks', width: 100,
			                	render: function (item){
			                		if(item.stocks==''||item.stocks==null||parseFloat(item.stocks)==0){
			                			return '0.0000';
			                		}
			                	 return item.stocks.toFixed(4);
			                }}    */
		                  ],
		                  enabledEdit: true,
		                  usePager: true, rownumbers: true, 
		                  pageSize:15,
		                  pageSizeOptions :[15,25,35],
		                  url:basic_Url+"/WHInventoryList.do",
		                  width: "100%", height:'100%',
		                  enabledSort:false
		                  });
			$("#pageloading").hide();
			});
		//导出物料
		function exportExcel(){
		   	var filtersStr = generateCondition();
			var path = basic_Url+"/HInventoryExcel.do"+encodeURI("?filters="+filtersStr+"&_search=true");
			window.open(path,"_blank");
		}
		function inExcel(){
			 $.dialog({id:"operate", title:"库存导入", content:"url:"+sys_context +"/logic/config/toStore.do", width:500, height:300, min:true, max:true , lock : true}).max();
		}
		</script>
	 
  </head>
 <body style="padding:10px" onload="createSearch()">  
       <div id="layout1">
          <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
			              <webres:displaycontroller elementId="LOGIC_EXCEL_IN_STORE" description="导入EXCEL">
			              <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="i" onclick="inExcel()">导入库存Excel</button></div></div></li>
			              </webres:displaycontroller>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="exportExcel()">导出Excel</button></div></div></li>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div>
      <div position="center" id="table1">
      </div>
      <div class="clear"></div>
    </body>
</html>